﻿CREATE PROCEDURE [acms].[PostControl_GetAllBySiteIdAndTypeName]
	@SiteId int, 
	@TypeName varchar(50),
	@SiteVersion DateTime
AS
	declare @tmp DateTime
	set @tmp = acms.GetPublishDate(@SiteId, @SiteVersion);
	
	
	
	SELECT a.*
	FROM [acms].[PostControl_View] a
		inner join [acms].[Post_View] b on a.[PostId] = b.Id
		inner join  [acms].[PostPositions] c on b.Id = c.PostId
	Where 
		a.TypeName = @TypeName
		and b.SiteId = @SiteId
		and isnull(c.PublishDate, '9999/12/31') = isnull(@tmp, '9999/12/31') 
RETURN 0;